﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using Model;
using System.Configuration;

namespace WebPortal.Controllers
{
    public class BaseController : Controller
    {
        /// <summary>
        /// 初始化登录信息
        /// </summary>
        /// <returns></returns>
        public LoginInfo loginInfo()
        {
            //LoginInfo info = new LoginInfo();
            //if (Request.Cookies["MDM_DBUser"] != null)
            //{
            //    info.Dbuser = Request.Cookies["MDM_DBUser"].Value;
            //    info.Dbpwd = Request.Cookies["MDM_DBPwd"].Value;
            //    info.ETLTargetCode = Request.Cookies["MDM_TargetCode"].Value;
            //    info.UserName = "superadmin";
            //    info.ETLTargetType = Int32.Parse(Request.Cookies["MDM_TargetType"].Value);
            //    info.UserIP = Request.Cookies["MDM_UserIP"].Value;
            //}
            return new LoginInfo();  
        }
        public BaseController()
        {

        }
        public ActionResult CheckLogin()
        {
            return View();
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string CheckLogin = ConfigurationManager.AppSettings["CheckLogin"].ToString();
            if (CheckLogin == "true" && (Request.Cookies["MDM_UserName"] == null || Session["MDM_UserName"] == null))
                HttpContext.Response.Write("<script>window.parent.location='/Account/LogOn';</script>");
            base.OnActionExecuting(filterContext);
        }
    }
}
